<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<script>
  var obj = {
    name: 'linqinghu',
    age: '27',
    birthday: '9.15',
    friend: ['老大', '老二', '老三', '老四', '老五', '老六', '老七'],
    doSomething: function () {
      var str = this.name + '的朋友是：';
      for (var i = 0; i < this.friend.length; i++) {
        str += ',' + this.friend[i];
      }
      return str
    }
  };

  function deepClone(obj) {
    var vv = null;
    if (typeof obj == 'object' && obj !== null) {

      vv = obj instanceof Array ? [] : {};

      for (var v in obj) {
        vv[v] = deepClone(obj[v]);
      }

    } else {
      vv = obj
    }
    return vv;
  }

  var obj2 = deepClone(obj);
  obj2.name = 'lincunbo';
  obj2.friend[0]='wo cao ';
  console.log(obj2);
  console.log(obj);
</script>
</body>
</html>